<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="FilterEdit.aspx.vb" Inherits="FilterEdit" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  <asp:SqlDataSource ID="sqlFilters" runat="server" ConnectionString="<%$ ConnectionStrings:VendorStatsConnectionString %>"
    InsertCommand="INSERT INTO FilterDates(DataSourceVendorId, StartDate, EndDate, FilterTypeId, AddDate, AddByUser, AgentCount) VALUES (@DataSourceVendorId, @StartDate, @EndDate, @FilterTypeId, @AddDate, @AddByUser, @AgentCount)"
    SelectCommand="SELECT FilterDates.FilterDateId, FilterDates.DataSourceVendorId, FilterDates.StartDate, FilterDates.EndDate, FilterDates.FilterTypeId, FilterDates.AddDate, FilterDates.AddByUser, FilterTypes.FilterType, View_DataSourceVendor.Source, FilterDates.AgentCount FROM FilterDates INNER JOIN FilterTypes ON FilterDates.FilterTypeId = FilterTypes.FilterTypeId INNER JOIN View_DataSourceVendor ON FilterDates.DataSourceVendorId = View_DataSourceVendor.DataSourceVendorId WHERE (FilterDates.FilterDateId = @FilterDateId)"
    UpdateCommand="UPDATE FilterDates SET DataSourceVendorId = @DataSourceVendorId, StartDate = @StartDate, EndDate = @EndDate, FilterTypeId = @FilterTypeId, AddDate = @AddDate, AddByUser = @AddByUser, AgentCount = @AgentCount WHERE (FilterDateId = @FilterDateId)">
    <SelectParameters>
      <asp:QueryStringParameter Name="FilterDateId" QueryStringField="FilterDateId" Type="Int32" />
    </SelectParameters>
    <UpdateParameters>
      <asp:Parameter Name="DataSourceVendorId" Type="Int32" />
      <asp:Parameter Name="StartDate" Type="DateTime" />
      <asp:Parameter Name="EndDate" Type="DateTime" />
      <asp:Parameter Name="FilterTypeId" Type="Byte" />
      <asp:Parameter Name="AddDate" Type="DateTime" />
      <asp:Parameter Name="AddByUser" Type="String" />
      <asp:Parameter Name="AgentCount" />
      <asp:Parameter Name="FilterDateId" Type="Int32" />
    </UpdateParameters>
    <InsertParameters>
      <asp:Parameter Name="DataSourceVendorId" Type="Int32" />
      <asp:Parameter Name="StartDate" Type="DateTime" />
      <asp:Parameter Name="EndDate" Type="DateTime" />
      <asp:Parameter Name="FilterTypeId" Type="Byte" />
      <asp:Parameter Name="AddDate" Type="DateTime" />
      <asp:Parameter Name="AddByUser" Type="String" />
      <asp:Parameter Name="AgentCount" />
    </InsertParameters>
  </asp:SqlDataSource>
  &nbsp;
  <asp:SqlDataSource ID="sqlDataSourceVendor" runat="server" ConnectionString="<%$ ConnectionStrings:VendorStatsConnectionString %>" SelectCommand="SELECT [DataSourceVendorId], [Source], [VendorId] FROM [View_DataSourceVendor] ORDER BY [Source]"></asp:SqlDataSource>
  <asp:SqlDataSource ID="sqlFilterTypes" runat="server" ConnectionString="<%$ ConnectionStrings:VendorStatsConnectionString %>"
    SelectCommand="SELECT [FilterTypeId], [FilterType] FROM [FilterTypes]"></asp:SqlDataSource>
  &nbsp;
  <asp:TextBox ID="txtVendorId" runat="server" Visible="False"></asp:TextBox>
  <br />
  <br />
  <asp:FormView ID="FormView1" runat="server" DataKeyNames="FilterDateId" DataSourceID="sqlFilters" Width="533px">
    <EditItemTemplate>
      <asp:Label ID="FilterDateIdLabel1" runat="server" Text='<%# Eval("FilterDateId") %>'
        Visible="False"></asp:Label><br />
      Data Source Vendor:
      <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="sqlDataSourceVendor"
        DataTextField="Source" DataValueField="DataSourceVendorId" SelectedValue='<%# Bind("DataSourceVendorId") %>'
        Width="212px">
      </asp:DropDownList><br />
      StartDate:
      <asp:TextBox ID="StartDateTextBox" runat="server" Text='<%# Bind("StartDate", "{0:d}") %>'></asp:TextBox><br />
      EndDate:
      <asp:TextBox ID="EndDateTextBox" runat="server" Text='<%# Bind("EndDate", "{0:d}") %>'></asp:TextBox><br />
      Filter Type:
      <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="sqlFilterTypes"
        DataTextField="FilterType" DataValueField="FilterTypeId" SelectedValue='<%# Bind("FilterTypeId") %>'
        Width="190px">
      </asp:DropDownList><br />
      AgentCount:
      <asp:TextBox ID="AgentCountTextBox" runat="server" Text='<%# Bind("AgentCount") %>'></asp:TextBox><br />
      AddDate:
      <asp:TextBox ID="AddDateTextBox" runat="server" Text='<%# Bind("AddDate") %>'></asp:TextBox><br />
      AddByUser:
      <asp:TextBox ID="AddByUserTextBox" runat="server" Text='<%# Bind("AddByUser") %>'></asp:TextBox><br />
      <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
        Text="Update"></asp:LinkButton>
      <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
        Text="Cancel"></asp:LinkButton>
    </EditItemTemplate>
    <InsertItemTemplate>
      Data Source Vendor:
      <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="sqlDataSourceVendor"
        DataTextField="Source" DataValueField="DataSourceVendorId" SelectedValue='<%# Bind("DataSourceVendorId") %>'
        Width="234px">
      </asp:DropDownList><br />
      StartDate:
      <asp:TextBox ID="StartDateTextBox" runat="server" Text='<%# Bind("StartDate", "{0:d}") %>'></asp:TextBox>
      <asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="StartDateTextBox"
        ErrorMessage="Please enter a date between 1/1/1900 and 1/1/2050" MaximumValue="1/1/2050"
        MinimumValue="1/1/1900" Type="Date" Display="Dynamic"></asp:RangeValidator><br />
      EndDate:
      <asp:TextBox ID="EndDateTextBox" runat="server" Text='<%# Bind("EndDate", "{0:d}") %>'></asp:TextBox>
      <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="StartDateTextBox"
        ControlToValidate="EndDateTextBox" ErrorMessage="Start Date should be less than end date"
        Operator="GreaterThan" Type="Date" Display="Dynamic"></asp:CompareValidator><br />
      FilterType:
      <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="sqlFilterTypes"
        DataTextField="FilterType" DataValueField="FilterTypeId" SelectedValue='<%# Bind("FilterTypeId") %>'
        Width="219px">
      </asp:DropDownList><br />
      AgentCount:
      <asp:TextBox ID="AgentCountTextBox" runat="server" Text='<%# Bind("AgentCount") %>'></asp:TextBox>
      <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Please enter a number from 1 - 28"
        MaximumValue="28" MinimumValue="0" Type="Integer" ControlToValidate="AgentCountTextBox" Display="Dynamic"></asp:RangeValidator><br />
      AddDate:
      <asp:TextBox ID="AddDateTextBox" runat="server" Text='<%# Bind("AddDate") %>'></asp:TextBox><br />
      AddByUser:
      <asp:TextBox ID="AddByUserTextBox" runat="server" Text='<%# Bind("AddByUser") %>'></asp:TextBox><br />
      <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
        Text="Insert"></asp:LinkButton>
      <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
        Text="Cancel"></asp:LinkButton>
      <asp:SqlDataSource ID="sqlFilterDisplay" runat="server" ConnectionString="<%$ ConnectionStrings:VendorStatsConnectionString %>"
    SelectCommand="SELECT FilterDates.StartDate, FilterDates.EndDate, FilterDates.AddDate, FilterDates.AddByUser, FilterTypes.FilterType, FilterDates.AgentCount FROM FilterDates INNER JOIN FilterTypes ON FilterDates.FilterTypeId = FilterTypes.FilterTypeId WHERE (FilterDates.DataSourceVendorId = @DataSourceVendorId)">
        <SelectParameters>
          <asp:ControlParameter ControlID="DropDownList3" Name="DataSourceVendorId" PropertyName="SelectedValue" />
        </SelectParameters>
      </asp:SqlDataSource>
      <br />
      <br />
      Current Filters<br />
      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="sqlFilterDisplay">
        <Columns>
          <asp:BoundField DataField="StartDate" DataFormatString="{0:d}" HeaderText="StartDate"
            HtmlEncode="False" ReadOnly="True" SortExpression="StartDate" />
          <asp:BoundField DataField="EndDate" DataFormatString="{0:d}" HeaderText="EndDate"
            HtmlEncode="False" ReadOnly="True" SortExpression="EndDate" />
          <asp:BoundField DataField="FilterType" HeaderText="FilterType" SortExpression="FilterType" />
          <asp:BoundField DataField="AgentCount" HeaderText="AgentCount" SortExpression="AgentCount" />
          <asp:BoundField DataField="AddDate" DataFormatString="{0:d}" HeaderText="AddDate"
            HtmlEncode="False" ReadOnly="True" SortExpression="AddDate" />
          <asp:BoundField DataField="AddByUser" HeaderText="AddByUser" SortExpression="AddByUser" />
        </Columns>
      </asp:GridView>
    </InsertItemTemplate>
    <ItemTemplate>
      FilterDateId:
      <asp:Label ID="FilterDateIdLabel" runat="server" Text='<%# Eval("FilterDateId") %>'></asp:Label><br />
      DataSourceVendorId:
      <asp:Label ID="DataSourceVendorIdLabel" runat="server" Text='<%# Bind("DataSourceVendorId") %>'></asp:Label><br />
      StartDate:
      <asp:Label ID="StartDateLabel" runat="server" Text='<%# Bind("StartDate") %>'></asp:Label><br />
      EndDate:
      <asp:Label ID="EndDateLabel" runat="server" Text='<%# Bind("EndDate") %>'></asp:Label><br />
      FilterTypeId:
      <asp:Label ID="FilterTypeIdLabel" runat="server" Text='<%# Bind("FilterTypeId") %>'></asp:Label><br />
      AddDate:
      <asp:Label ID="AddDateLabel" runat="server" Text='<%# Bind("AddDate") %>'></asp:Label><br />
      AddByUser:
      <asp:Label ID="AddByUserLabel" runat="server" Text='<%# Bind("AddByUser") %>'></asp:Label><br />
      FilterType:
      <asp:Label ID="FilterTypeLabel" runat="server" Text='<%# Bind("FilterType") %>'></asp:Label><br />
      Source:
      <asp:Label ID="SourceLabel" runat="server" Text='<%# Bind("Source") %>'></asp:Label><br />
      AgentCount:
      <asp:Label ID="AgentCountLabel" runat="server" Text='<%# Bind("AgentCount") %>'></asp:Label><br />
      <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
        Text="Edit"></asp:LinkButton>
      <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
        Text="New"></asp:LinkButton>
    </ItemTemplate>
    <EmptyDataTemplate>
      empty data?
    </EmptyDataTemplate>
  </asp:FormView>
</asp:Content>

